//
//  GetMoneyTextFieldCell.m
//  CenturyCity
//
//  Created by beisheng03 on 2018/1/4.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "GetMoneyTextFieldCell.h"

@interface GetMoneyTextFieldCell ()
@property (weak, nonatomic) IBOutlet UILabel *leftLabel;
@property (weak, nonatomic) IBOutlet UITextField *rightTextField;
@property (weak, nonatomic) IBOutlet UIImageView *leftImageView;
@property (weak, nonatomic) IBOutlet UILabel *rightLabel;

@end

@implementation GetMoneyTextFieldCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.leftLabel.font = MYFONT(16);
    
    self.rightTextField.font = MYFONT(14);
    
    
    self.rightLabel.textColor = [UIColor redColor];
    
    self.rightLabel.font = MYFONT(14);
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.rightTextField];

    
}

- (void)setIndex:(NSIndexPath *)index{
    _index = index;
    
    
    self.rightTextField.font = MYFONT(14);
    
    self.rightTextField.placeholder = @"";

    if ([self.type isEqualToString:@"电费"]  || [self.type isEqualToString:@"网费"]) {
        
        self.rightTextField.font = [UIFont boldSystemFontOfSize:17];
        self.rightTextField.textColor = [UIColor blackColor];
        
        if ([self.type isEqualToString:@"电费"]) {
            
            if (index.row == 0) {
                
                self.leftLabel.text = @"户号 :";
                
                self.leftImageView.image = [UIImage imageNamed:@"payMoney_000"];
                
                self.rightTextField.placeholder = @"ATM/Phone Reference No.";
                
                [self.rightTextField becomeFirstResponder];
                
                self.rightTextField.keyboardType = UIKeyboardTypeNumberPad;
                self.rightLabel.text = @"";
                
           
            } else {
                

                    
                    if (index.row == 2) {
                        
                        self.rightLabel.text = @"P";
                        self.leftLabel.text = @"缴费金额 :";
                        self.leftImageView.image = [UIImage imageNamed:@"payMoney_001"];
                        self.rightTextField.keyboardType = UIKeyboardTypeNumberPad;
                        self.rightTextField.placeholder = @"Total Amount Due";
                        
                    } else {
                        
                        self.rightLabel.text = @"";
                        self.leftLabel.text = @"账单号 :";
                        self.rightTextField.placeholder = @"Meralco Reference No.";
                        
                        self.leftImageView.image = [UIImage imageNamed:@"payMoney_002"];
                        self.rightTextField.keyboardType = UIKeyboardTypeNumberPad;
                    }
                
                
                
                
            }
            
        }else{
            
            if (index.row == 1) {
                
                self.leftLabel.text = @"户号 :";
                
                self.leftImageView.image = [UIImage imageNamed:@"payMoney_000"];
                
                self.rightTextField.placeholder = @"Account Number";
                
                [self.rightTextField becomeFirstResponder];
                
                self.rightTextField.keyboardType = UIKeyboardTypeNumberPad;
                self.rightLabel.text = @"";
                
     
            } else {
//                fdfdsfd/

                    if (index.row == 2) {
                        
                        
                        self.rightLabel.text = @"";
                        self.leftLabel.text = @"账单号 :";
                        self.rightTextField.placeholder = @"Telephone Number";
                        
                        self.leftImageView.image = [UIImage imageNamed:@"payMoney_002"];
                        self.rightTextField.keyboardType = UIKeyboardTypeNumberPad;
                        
                       
                    } else {
                        
                        self.rightLabel.text = @"P";
                        self.leftLabel.text = @"缴费金额 :";
                        self.leftImageView.image = [UIImage imageNamed:@"payMoney_001"];
                        self.rightTextField.keyboardType = UIKeyboardTypeNumberPad;
                        self.rightTextField.placeholder = @"Total Amount Due";
                        
                     
                    }
                
                
                
                
            }
            
        }

        
       
        
    }else{
        
        self.rightLabel.text = @"";
        self.rightTextField.textColor = darkGray;
        
        if (index.row == 0) {
            
            self.leftLabel.text = @"持卡人 :";
            
            self.leftImageView.image = [UIImage imageNamed:@"getMoney000"];
            
            
            [self.rightTextField becomeFirstResponder];
            
            self.rightTextField.keyboardType = UIKeyboardTypeDefault;
            
            //        self.rightTextField.placeholder = @"姓名";
        } else if (index.row == 1){
            
            self.leftLabel.text = @"手机号 :";
            self.leftImageView.image = [UIImage imageNamed:@"getMoney001"];
            self.rightTextField.keyboardType = UIKeyboardTypeNumberPad;
            
        }else if (index.row == 2){
            
            self.leftLabel.text = @"支行名称 :";
            self.leftImageView.image = [UIImage imageNamed:@"getMoney003"];
            self.rightTextField.keyboardType = UIKeyboardTypeDefault;
            
        }else if (index.row == 3){
            self.leftLabel.text = @"银行卡号 :";
            self.leftImageView.image = [UIImage imageNamed:@"getMoney004"];
            self.rightTextField.keyboardType = UIKeyboardTypeNumberPad;
            
        }else if (index.row == 4){
            self.leftLabel.text = @"提现金额 :";
            self.rightLabel.text = @"P";
            self.leftImageView.image = [UIImage imageNamed:@"getMoney005"];
            self.rightTextField.keyboardType = UIKeyboardTypeDecimalPad;
            
        }else{
            
            self.rightTextField.keyboardType = UIKeyboardTypeDefault;
        }
        
        
        
    }
    
    
   
    
    
}


- (void)setModel:(GetMoneyInfoModel *)model{
    
    _model = model;
    
    
    if ([self.type isEqualToString:@"电费"]  || [self.type isEqualToString:@"网费"]) {
        
        if ([self.type isEqualToString:@"电费"]) {
            
            if (self.index.row == 0) {
                
                if (_model.huNumber.length > 0) {
                    
                    self.rightTextField.text = _model.huNumber;
                }
                
            } else{
                
                    if (self.index.row == 2) {
                        if (_model.money.length > 0) {
                            
                            self.rightTextField.text = _model.money;
                        }
                    } else {
                        if (_model.billNumber.length > 0) {
                            
                            self.rightTextField.text = _model.billNumber;
                        }
                    }
                    
                
            }
            
        } else {
            
//            fdsfdsf
            if (self.index.row == 1) {
                
                if (_model.huNumber.length > 0) {
                    
                    self.rightTextField.text = _model.huNumber;
                }
                
            } else{
                
       
                    
                    if (self.index.row == 2) {
                        
                        
                        if (_model.billNumber.length > 0) {
                            
                            self.rightTextField.text = _model.billNumber;
                        }
                        
                        
                    } else {
                        
                        if (_model.money.length > 0) {
                            
                            self.rightTextField.text = _model.money;
                        }
                        
                    }
                    
                
                
                
                
            }
        }
        
        
        
        
    } else {
        
        
        
        if (self.index.row == 0) {
            
            if (_model.realname.length > 0) {
                
                self.rightTextField.text = _model.realname;
            }
            
        } else if (self.index.row == 1){
            
            if (_model.mobile.length > 0) {
                
                self.rightTextField.text = _model.mobile;
            }
            
        }else if (self.index.row == 2){
            if (_model.bank_name.length > 0) {
                
                self.rightTextField.text = _model.bank_name;
            }
        }else if (self.index.row == 3){
            
            if (_model.account_number.length > 0) {
                
                self.rightTextField.text = _model.account_number;
            }
            
        }else if (self.index.row == 4){
            
            if (_model.cash.length > 0) {
                
                self.rightTextField.text = _model.cash;
            }
            
        }
        
    }
    
   
    
}


- (void)textChange{
    
//    self.model.trueName = self.rightTextField.text;
    
    
    if ([self.type isEqualToString:@"电费"]  || [self.type isEqualToString:@"网费"]) {
        
        if ([self.type isEqualToString:@"电费"]) {
            if (self.index.row == 0) {
                
                self.model.huNumber = self.rightTextField.text;
                
            } else{
                
                    if (self.index.row == 2) {
                        self.model.money = self.rightTextField.text;
                        
                    } else {
                        self.model.billNumber = self.rightTextField.text;
                        
                    }
                    
                }
                
                
                
            
        } else {
            
//            fdsfdsf
            if (self.index.row == 1) {
                
                self.model.huNumber = self.rightTextField.text;
                
            } else{
                

                    
                    if (self.index.row == 2) {
                        
                        self.model.billNumber = self.rightTextField.text;

                        
                    } else {
                        
                        self.model.money = self.rightTextField.text;

                    }
                    
                }
                
                
                
            
        }
        
      
        
        
    } else {
        
        if (self.index.row == 0) {
            
            self.model.realname = self.rightTextField.text;
            
        } else if (self.index.row == 1){
            
            self.model.mobile = self.rightTextField.text;
            
            
        }else if (self.index.row == 2){
            
            self.model.bank_name = self.rightTextField.text;
            
        }else if (self.index.row == 3){
            
            self.model.account_number = self.rightTextField.text;
            
            
        }else if (self.index.row == 4){
            
            self.model.cash = self.rightTextField.text;
            
            
        }
    }
    
   
    
}











- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
